xlv.obj.layerPanes={
	extend:function(){
	},
	implement:function(){
		this.implement('xlv.imp.active');
	},
	create:function(tag){
		var div=document.createElement((tag||'div'));
		div.setAttribute('xlvobject','xlv.obj.layerPanes');
		Element.addClassName(div,'class_layerPanes');
		return div;
	},
	properties:{
		defaultActivatedIndex:0,
		ajaxPanes:null //[{properties:{paneURL:'blank_pane.html',paneProperties:null,paneMethod:null},method:{}},]
	},
	method:{
		construct:function(){
			Element.addClassName(this,'class_layerPanes');
			var panes=this.$P.ajaxPanes;
			if(panes){
				for(var i=0;i<panes.length;++i){
					var pane=xlv.sys.newObject('ajaxPane',panes[i].properties,panes[i].method);
					this.appendChild(pane);
					this.styleFor(pane,i);
				}
			}
		},
		initial:function(){
			var panes=this.getPanes(),index=this.$P.defaultActivatedIndex;
			if(panes.length>0){
				for(var i=0,n=panes.length;i<n;++i){
					if(Element.hasClassName(panes[i],'activated'))index=i;
					else Element.removeClassName(panes[i],'activated');
				}
				this.activePane(index);
			}
		},
		styleFor:function(pane,index){
		},
		addAjaxPane:function(ajax_properties,ajax_method,index){
			index=(index>=0)?index:this.getPanes().length;
			//var pane=xlv.sys.newInstance(this,'ajaxPane',{paneURL:url,paneProperties:properties,paneMethod:method},null,this.getPane(index));
			var pane=xlv.sys.newInstance(this,'ajaxPane',ajax_properties,ajax_method,this.getPane(index));
			this.styleFor(pane,this.getIndex(pane));
			return pane;
		},
		addPane:function(properties,method,index){
			index=(index>=0)?index:this.getPanes().length;
			var pane=xlv.sys.newInstance(this,'pane',properties,method,this.getPane(index));
			this.styleFor(pane,this.getIndex(pane));
			return pane;
		},
		removePane:function(index){
			var pane=this.getPane(index);
			if(pane){
				xlv.sys.dispose(pane,true);
			}
		},
		setPane:function(index,url,properties,method){
			var pane=this.getPane(index);
			if(pane)pane.request(url,properties,method);
		},
		getPanes:function(){
			return xlv.util.children(this,{xlvobject:/xlv.obj.ajaxPane|xlv.obj.pane/},false);
		},
		getActivatedPane:function(){
			return this.active_getActivated();
		},
		getActivatedIndex:function(){
			return this.getIndex(this.getActivatedPane());
		},
		getIndex:function(pane){
			var panes=this.getPanes();
			for(var i=0,n=panes.length;i<n;++i)	if(panes[i]==pane) return i;
			return -1;
		},
		getPane:function(index){
			if((typeof index)=='undefined'||index==null) return null;
			var panes=this.getPanes();
			return (index<0||index>=panes.length)?null:panes[index];
		},
		activePane:function(index){
			var panes=this.getPanes();
			if(index>=0&&index<panes.length&&this.active_activatable(panes[index])){
				this.active_item(panes[index]);
			}
		}
	}
};
